package com.zyc.serviceImpl;

import com.zyc.annotation.RpcService;
import com.zyc.bean.Hello;
import com.zyc.service.HelloService;
import lombok.extern.slf4j.Slf4j;

/**
 * @author zyc
 * @create 2022--05--10 15:50
 */
@Slf4j
@RpcService
public class HelloServiceImpl implements HelloService {

    static {
        System.out.println("helloServiceImpl被创建");
    }

    @Override
    public String hello(Hello hello) {
        log.info("HelloServiceImpl收到:【{}】", hello.getMessage());
        String result = "!!!远程调用成功!!!发送的内容是：【" + hello.getMessage() + "】发送的细节是：【" + hello.getDescription() + "】";
        log.info("HelloServiceImpl返回:{}", result);
        return result;
    }

    @Override
    public void sleep(long mSec) {
        try {
            log.info("线程{}开始睡眠{}秒", Thread.currentThread().getName(), mSec / 1000);
            Thread.sleep(mSec);
            log.info("线程{}醒来", Thread.currentThread().getName());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}